package com.vhly.remoteapi.yahoo.contact.field;

import com.vhly.remoteapi.yahoo.contact.FieldValue;
import org.w3c.dom.Element;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: vhly[FR]
 * Date: 2010-12-5
 * Time: 17:13:10
 * Email: vhly@163.com
 */
public class Birthday extends FieldValue {

    public int day;
    public int month;
    public int year;

    /**
     * read object from DataInput
     *
     * @param din DataInput
     */
    @Override
    public void readObject(DataInput din) throws IOException {
        day = din.readShort();
        month = din.readShort();
        year = din.readShort();
    }

    /**
     * Write object to DataOutput
     *
     * @param dout DataOutput
     */
    @Override
    public void writeObject(DataOutput dout) throws IOException {
        dout.writeShort(day);
        dout.writeShort(month);
        dout.writeShort(year);
    }

    /**
     * Serial content to XML
     *
     * @return String
     */
    @Override
    public String toXML() {
        String ret = null;
        StringBuffer sb = new StringBuffer();
        sb.append("<day>").append(day).append("</day>");
        sb.append("<month>").append(month).append("</month>");
        sb.append("<year>").append(year).append("</year>");
        ret = sb.toString();
        sb = null;
        return ret;
    }

    /**
     * Parse Element
     *
     * @param el Element
     */
    @Override
    public void parse(Element el) {
    }
}
